import { Redirect } from 'umi';

import LocalCache from '../../utils/cache';
export default (props: any) => {
  const useAuth = () => {
    return LocalCache.getCache('token') ? true : false;
  };

  const isLogin = useAuth();
  if (isLogin) {
    return <div>{props.children} </div>;
  } else {
    return <Redirect to="/login" />;
  }
};
